package demo.netty.netty.bytebuf;


import demo.netty.util.ByteUtils;

/**
 * bytebuf 使用例子
 */
public class ByteBufDemo {

    public static void main(String[] args) {
        String hex = "552f00a000001004000289458578000000000000000000000000787906402210260486896f544512037169869AE955";
        byte[] bytes = ByteUtils.hexStringToBytes(hex);
        byte[] crc = {(byte) 0x9A, (byte) 0xE9};
        byte[] tmp = {(byte) 0x2f, (byte) 0x00};
        System.out.println(ByteUtils.getLittleEndianValueForBytes(crc));
        System.out.println(ByteUtils.getLittleEndianValueForBytes(tmp));
        byte[] newByte = new byte[bytes.length - 3];
        System.arraycopy(bytes, 0, newByte, 0, newByte.length);
        int crc16 = ByteUtils.calculateCRCMod16(newByte);
        System.out.println(crc16);

        String deviceId = "8945857800000000";
        byte[] deviceIdBytes = ByteUtils.hexStringToBytes(deviceId);
        System.out.println(ByteUtils.getLittleEndianValueForBytes(deviceIdBytes));
    }

}
